import java.util.HashSet;

public class Solution {

    public class TreeNode {
        int val = 0;
        TreeNode left = null;
        TreeNode right = null;

        public TreeNode(int val) {
            this.val = val;

        }

    }
    public int numJewelsInStones(String jewels, String stones) {
        HashSet<Character> set = new HashSet<>();
        HashSet<Integer> set1 = new HashSet<>();
        for (int i=0; i<jewels.length(); i++) {
            char ch = jewels.charAt(i);
            set.add(ch);
        }
        int count = 0;
        for (int i = 0; i < stones.length(); i++) {
            char ch = stones.charAt(i);
            if(set.contains(ch)){
                count++;
            }
        }
        return count;
    }

    TreeNode pre = null;
    TreeNode head = null;
    public TreeNode Convert(TreeNode pRootOfTree) {
        if(pRootOfTree == null){
            return null;
        }

        Convert(pRootOfTree.left);
        if(pre == null){
            pre = pRootOfTree;
            head = pRootOfTree;
        }else{
            pre.right = pRootOfTree;
            pRootOfTree.left = pre;
            pre = pRootOfTree;
        }
        Convert(pRootOfTree.right);
        return head;
    }

    public String badKeyboard(String s, String t){
        HashSet<Character> set = new HashSet<>();
        HashSet<Character> set2 = new HashSet<>();

        for (int i = 0; i < s.length(); i++) {
            set.add(s.charAt(i));
        }
        for (int i = 0; i < t.length(); i++) {
            set2.add(t.charAt(i));
        }

        String str = null;
        for (int i = 0; i < s.length(); i++) {
            if(!set2.contains(s.charAt(i))){
                str += s.charAt(i);
            }
        }
        return str.toUpperCase();

    }
}
